package com.ruoyi.sale.controller;



import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.utils.SecurityUtils;
import com.ruoyi.sale.domain.Record;
import com.ruoyi.sale.domain.Sale;
import com.ruoyi.sale.service.IRecordService;
import com.ruoyi.sale.service.ISaleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.List;

@RestController
@RequestMapping("/record")
public class RecordController extends BaseController {

    @Autowired
    private IRecordService recordService;

    /**
     * 新增领取记录
     */
//    @Log(title = "营销管理", businessType = BusinessType.INSERT)
//    @PostMapping
//    public AjaxResult add(@Validated @RequestBody Sale sale)
//    {
//        if (!saleService.checkSaleNameUnique(sale))
//        {
//            return error("新增优惠券失败'" + sale.getName() + "'失败，优惠券已存在");
//        }
//        sale.setCreateBy(SecurityUtils.getUsername());
//        return toAjax(saleService.insertSale(sale));
//    }

    /**
     * 显示领取记录
     */
    @GetMapping("/list")
    public TableDataInfo list(Record record)
    {
        startPage();
        List<Record> list = recordService.selectRecordList(record);
        return getDataTable(list);
    }

}
